func find<%= resource_name %>ByList(client *golangsdk.ServiceClient, link, resourceID string) (interface{}, error) {
<% _, pp = list_api.pagination_param -%>
<% if pp.eql?("marker") -%>
    marker := ""
    for {
        url := strings.Sprintf(link, marker)
        r, err := send<%= resource_name %><%= titlelize(list_api.name) %>Request(client, url)
        if err != nil {
            return nil, err
        }
        r1 := r.([]interface{})
        if len(r1) == 0 {
            break
        }
        for _, item := range r1 {
            val, ok := item.(map[string]interface{})["<%= list_api.resource_id_path -%>"]
            if ok && resourceID == convertToStr(val) {
                return item, nil
            }
        }
        marker = val["<%= list_api.resource_id_path -%>"]
    }
<% elsif pp.eql?('offset') -%>
    offset := 0
    for {
        url := strings.Sprintf(link, offset)
        r, err := send<%= resource_name %><%= titlelize(list_api.name) %>Request(client, url)
        if err != nil {
                return nil, err
        }
        r1 := r.([]interface{})
        if len(r1) == 0 {
            break
        }
        for _, item := range r1 {
            val, ok := item.(map[string]interface{})["<%= list_api.resource_id_path -%>"]
            if ok && resourceID == convertToStr(val) {
                return item, nil
            }
        }
        offset += 1
    }
<% elsif pp.eql?('start') -%>
    start := 1
    for {
        url := strings.Sprintf(link, start)
        r, err := send<%= resource_name %><%= titlelize(list_api.name) %>Request(client, url)
        if err != nil {
                return nil, err
        }
        r1 := r.([]interface{})
        if len(r1) == 0 {
            break
        }
        for _, item := range r1 {
            val, ok := item.(map[string]interface{})["<%= list_api.resource_id_path -%>"]
            if ok && resourceID == convertToStr(val) {
                return item, nil
            }
        }
        start += len(r.([]interface{}))
    }
<% else -%>
    r, err := send<%= resource_name %><%= titlelize(list_api.name) %>Request(client, link)
    if err != nil {
            return nil, err
    }
    for _, item := range r.([]interface{}) {
        val, ok := item.(map[string]interface{})["<%= list_api.resource_id_path -%>"]
        if ok && resourceID == convertToStr(val) {
            return item, nil
        }
    }
<% end -%>

    return nil, fmt.Errorf("Error finding the resource by list api")
}
